/**
 * Created by xu on 2016/1/3.
 * 穿跨域
 */
//点击穿跨越标签过后执行的方法
function afterClickCrossTab(){
    getCrossOverList();//获取list列表
}

function delCrossOver(id){
    if (isEmpty(id)){
        alert("删除id不能为空!");
        return;
    }
    if (!confirm("是否确定删除?")){
        return;
    }
    $().invoke(
        p_path+"/pipe/data/cross/delPipeCrossRecord.json",
        {"id":id},
        [function(m,r){
            if (r=='success'){
                $("#pipeCrossOver").refresh();
            }
        },function(m,r){
            alert(r);
        }]
    )

}

//根据条件查询穿跨越列表
function queryCrossOver(){
    var vR=$("#crossQueryForm").validationEngine("validate");
    if (!vR){
        return;
    }
    var data_=$("#crossQueryForm").serializeFormJSON();
    $("#pipeCrossOver").selectDataAfterSetParm(data_);
}


function getCrossOverList(){
    var col=[
        {title:"管道名称",name:"lineName",width:"10%",align:"center"},
        {title:"管段名称",name:"segmentName",width:"10%",align:"center"},
       // {title:"穿跨越编号",name:"crossingNumber",width:"5%",align:"center",showTips:true},
        {title:"穿跨越名称",name:"crossingName",width:"5%",align:"center",showTips:true},
        {title:"穿跨越类型",name:"crossingType",width:"5%",align:"center"},
        {title:"穿跨越对象",name:"crossingTarget",width:"5%",align:"center"},
        {title:"穿跨越方式",name:"crossingMethod",width:"5%",align:"center"},
       // {title:"起点绝对距离",name:"fromMileage",width:"10%",align:"center",format:function(json){return nvl_(json.fromMileage)}},
        {title:"穿跨越长度(m)",name:"crossingLength",width:"10%",align:"center",format:function(json){return nvl_(json.crossingLength,"",0)}},
        {title:"详情 删除",name:"",width:"5%",align:"center",format:dataDeatil}
        /*{title:"删除",name:"",width:"5%",align:"center",format:dataDel}*/
    ];
    $("#pipeCrossOver").initTable({
        url: p_path + "/pipe/data/cross/queryPipeCrossList.json",
        isBindDataToTr:true,
        columnData: col,
        doubleRowMode:true,
        isrowClick:true,
        maxHeightMode:false,
        //rowClickMethod:pipeCrossOverRowClick,
        selectDataNow:true
    });
}

function dataDeatil(json){
    var h="<li class=\"w12-4-3-1 no-right\" style='list-style: none;position: relative'>" +
        "<em onclick='opDetail(this,showUl)' class=\"xq-icon new\"></em>" +
        "<em onclick=delCrossOver('"+json.id+"') class=\"delet2 new\"></em></li>";
    return h;
}




function pipeCrossOverRowClick(data,obj,orderNum){

    try {
        var eventTarget_ = event.target || event.srcElement;
        if (eventTarget_ != null && eventTarget_ != document&& eventTarget_.tagName=="EM"
            && $(eventTarget_).hasClass("xq-icon")) {
            var t=$("#pipeCrossOver"+orderNum,$("#pipeCrossOver"));
            $("td",t).html(showUl(data));
            t.fadeToggle();
            return false;
            /*if ($(eventTarget_).hasClass("delet2")) {
                return;
            }*/
        }
    } catch (e) {
        console.log(e)
    }


}

/*
function dataDel(){
    var h="<li class=\"w12-4-3-1 no-right\" style='list-style: none;'><em class=\"delet2\"></em></li>";
    return h;
}*/
//导出穿跨越excel
function exportPipeCross(){
    //var juliStart=nvl_($("#juliStart").val());
    //var juliEnd=nvl_($("#juliEnd").val());
    var data_=$("#crossQueryForm").serializeFormJSON();
    var p=json2UrlParam(data_);
    backgroundExport(p_path+"/pipe/data/cross/pipeCrossExcelExport.json?"+p);
    //window.open(p_path+"/pipe/data/cross/pipeCrossExcelExport.json?"+p);
    //location.href=p_path+"/pipe/data/cross/pipeCrossExcelExport.json?"+p;
}

function downPipeCross(){
    location.href=p_path+"/public/down/downCrossOverTemplate.json";
}

function showUl(json){
    var ulHtml="<div class='info-tr'>";
    ulHtml+=("<div class=\"show-ul \">");
    ulHtml+=("     <ul class=\"show-list\">");
    ulHtml+=("         <li title=>");
    ulHtml+=("             <span class=\"s1\">管道名称:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.lineName)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">管段名称:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.segmentName)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">穿跨越编号:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.crossingNumber)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">穿跨越名称:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.crossingName)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">穿跨越类型:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.crossingType)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">穿跨越方式:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.crossingMethod)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">穿跨越长度(m):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.crossingLength,"",0)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">起点绝对距离(m):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.fromMileage,"",0)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">起点最近参考点:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.fromReference)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">起点相对最近参考点距离(m):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.fromReferenceDistance,"",0)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">终点绝对距离(m):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.toMileage,"",0)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">终点最近参考点:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.toReference)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">终点相对最近参考点距离(m):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.toReferenceDistance,"",0)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">管节数:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.number)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">材质:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.material)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">壁厚（mm):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.wallThickness)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">稳管措施:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.pipeStableMeasures)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">是否有套管:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.isSleeve)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">防护层材料:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.coatingMaterial)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li >");
    ulHtml+=("             <span class=\"s1\">防护层厚度(mm):</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.coatingThickness)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">施工单位:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.assemblyCompany)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">监理单位:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.inspectingCompany)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">检测单位:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.testingCompany)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">竣工资料编号:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.completionDataNumber)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">记录人:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.recorder)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">记录时间:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.recordtime)+"</span>");
    ulHtml+=("         </li>");
    ulHtml+=("         <li>");
    ulHtml+=("             <span class=\"s1\">统一编号:</span>");
    ulHtml+=("             <span class=\"s2\">"+nvl_(json.code)+"</span>");
    ulHtml+=("         </li>");

    ulHtml+=("         <li class=\"last-li\" >");
    ulHtml+=("             <span class=\"s1\">备注:</span>");
    ulHtml+=("             <span class=\"s2\"><textarea placeholder=\"备注描述\">"+nvl_(json.createRemark)+"</textarea></span>");
    ulHtml+=("         </li>");
    ulHtml+=("     </ul>");
    ulHtml+=(" </div></div>");
    return ulHtml;
}